package com.ztools.pc.controller.sys;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ztools.common.model.pc.sys.UserRole;
import com.ztools.common.util.common.PageUtil;
import com.ztools.common.util.common.Result;
import com.ztools.pc.service.sys.UserRoleService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:一口香菜
 * @Date: 2023/3/8  21:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/user/role")
public class UserRoleController {

    @Resource
    private UserRoleService userRoleService;

    @RequestMapping("/list")
    public Result findList(@RequestBody PageUtil<UserRole> pageUtil) {
        Page<UserRole> list = userRoleService.findList(pageUtil);
        return list != null ? Result.success("查询成功").data(list) : Result.error();
    }

    @RequestMapping("/add-list")
    public Result addList(@RequestBody List<UserRole> userRole) {
        boolean b = userRoleService.addList(userRole);
        return b ? Result.success("添加成功") : Result.error("添加失败");
    }

}
